function main() {
    debugger
    let self = this;
    let treeEle = self.$$("tree_panel_8u0z0f");
    let departmentId = api.USER_INFO().departmentId || "";
    const params = [{
        name: "unitUuIds",
        valueContent: departmentId
    }];

    setTimeout(() => {
        debugger

        // get-senior-domain-unit-id  "ds_mod:43997d3e-eaf4-4d33-b832-26bc911a6187"
        // get-domain-unit-region-type" "ds_mod:627f14ac-5e03-4177-9fad-e1e709671a37"
        // 获取区划层级
        api.DATA_SOURCE_EXECUTE("ds_mod:627f14ac-5e03-4177-9fad-e1e709671a37", "ddcat", params, [], "").then(rs => {
                if (!rs.hasError) {
                    try {
                        const result = rs.result;
                        // 顶级层级
                        if (result.type == 0 || result.type == 9) {
                            treeEle.params.unitId = 0;
                            treeEle.params.flag = 0;
                            treeEle.doQuery();
                        } else {
                            // 获取配置项为执法主体或单位
                            api.EXEC_FORMULA("ENTITY_SELECT_ONE('ds_tbl:t_47ac6252fc43469baa839f533f51438d',ITEM_VALUE,QUERY_EQ(name,'LAW_CHECK_SENIOR_DOMAIN_MODE'))").then(res => {
                                if (res.result == '0') {
                                    api.DATA_SOURCE_EXECUTE("ds_api:053c64fa-424c-46c6-b5ec-556b73aab375", "api", params, [], "").then(rs => {
                                        debugger;
                                        if (!rs.hasError) {
                                            try {
                                                const result = JSON.parse(rs.result);
                                                let unitId = ""
                                                let flag = 0;
                                                if (result.result) {
                                                    unitId = result.result.unit_id || "";
                                                    flag = 1
                                                }
                                                treeEle.params.unitId = unitId;
                                                treeEle.params.flag = flag;
                                                treeEle.doQuery();
                                            } catch (error) {
                                                console.error('解析结果失败:', error);
                                            }
                                        } else {
                                            console.error('API 请求返回错误:', rs.message);
                                        }
                                    });
                                } else {
                                    // 执法主体
                                    // get-senior-domain-law-subject_id "ds_mod:ec7ce26f-94a4-4ea0-8172-41d5aa2bc372"
                                    api.DATA_SOURCE_EXECUTE("ds_mod:ec7ce26f-94a4-4ea0-8172-41d5aa2bc372", "api", params, [], "").then(rs => {
                                        debugger;
                                        if (!rs.hasError) {
                                            try {
                                                const result = rs.result;
                                                let unitId = ""
                                                let flag = 0;
                                                if (result.result) {
                                                    unitId = result.result.unit_id || "";
                                                    flag = 1
                                                }
                                                treeEle.params.unitId = unitId;
                                                treeEle.params.flag = flag;
                                                treeEle.doQuery();
                                            } catch (error) {
                                                console.error('解析结果失败:', error);
                                            }
                                        } else {
                                            console.error('API 请求返回错误:', rs.message);
                                        }
                                    });
                                }
                            })
                        }
                    } catch (error) {
                        console.error('解析结果失败:', error);
                    }
                } else {
                    console.error('API 请求返回错误:', rs.message);
                }
            }
        )
    })
}


